<?php
/**
 * Created by zxk7516@foxmail.com  Date: 2017/10/20  Time: 16:05
 */

namespace App\Listeners;

use App\Events\SetWxMenu as Event;
use EasyWeChat\Foundation\Application;
use EasyWeChat\Support\Log;
use Illuminate\Contracts\Queue\ShouldQueue;


class SetWxMenu implements ShouldQueue
{
    public function handle(Event $msg)
    {
        $app = new Application(config('wechat'));
        $menu = $app->menu;
        $buttons = json_decode( $msg->menu );
        $menu->add($buttons);
    }

    public function failed(Event $msg, $event)
    {
        dd($msg);
        Log::info('发送失败: 模板数据' . json_encode($msg));
    }
}